
<?

$deltager = new player_character();
$deltager->find_alle_rollespillere_karakterer();

$user_pcs = $deltager->alle_rollespillere_karakterer;

//	print_r($user_pcs);
?>
<button style="float:right" class="opret_ny_deltager_link rubrik" type="button" class="rubrik " >Opret ny deltager</button><br>
<div id="opret_ny_deltager_form" style="display:none;overflow:auto;width:100%;">

<?

//$this->load->view("gamemaster/pc_haandtering");
echo form_open("admin/create_user"); 


echo "<p class='rubrik'><span style='width:100px;'>Brugernavn:</b> ".form_input("username","")."</p>";
echo "<p class='rubrik'><b style='width:100px;'>Fornavn:</b> ".form_input("rollespiller_fornavn","")."</p>";
echo "<p class='rubrik'><b style='width:100px;'>Efternavn:</b> ".form_input("rollespiller_efternavn","")."</p>";
echo "<p class='rubrik'><b style='width:100px;'>Email-adresse:</b> ".form_input("email_adress","")."</p>";
echo "<p class='rubrik'><b style='width:100px;'>Administrator</b> ".form_checkbox('admin', '1', FALSE)."</p>";
echo "<p class='rubrik'><b style='width:100px;'>Aktiv</b> ".form_checkbox('aktiv', '1', TRUE)."</p>";
echo "<p id='role-pick'>Tildel rolle: ".br();

$none = array(
    'name'        => 'pc_pick',
    'id'          => 'check_none',
    'value'       => 'none',
    'checked'     => TRUE,

    );

$new = array(
    'name'        => 'pc_pick',
    'id'          => 'check_new_pc',
    'value'       => 'new',
    'checked'     => FALSE,

    );

$existing = array(
    'name'        => 'pc_pick',
    'id'          => 'check_exist_pc',
    'value'       => 'existing',
    'checked'     => FALSE,

    );

echo form_radio($none)."<span> Ingen rolle </span> ".br();
echo form_radio($new)."<span> Opret ny karakter </span> ".br();
echo form_radio($existing)." <span >giv eksisterende rolle</span></p>";



//echo form_input("role","none","id='role-holder'");

echo "<div id='new_player_character' style='display:none;'>";
$this->load->view("forms/opret_individ_form");

echo "</div>";


echo "<div id='eksisting_character' style='display:none;'>";
echo "Søg efter en ny karakter";

echo "</div>";


//echo br()."<b>Processen blev afviklet i tidsrummet</b>".br();
//echo form_input("exec_start","dd-mm-åååå tt:MM");
//echo " til ".form_input("exec_slut","dd-mm-åååå tt:MM").br();


echo "<div style='float:right;'>".form_submit("","Opret ny deltager","class='rubrik'")."</div>";
echo form_close();


?>



</div>
<h2 class="rubrik">
Rollespiller
<span style="float:right;">Aktiv</span>
</h2><br>
<?
//print_r($rollespillere_karakterer);



//$this->table->set_heading(array('<h4>Karakter</h4>', '<h4>Rollespiller</h4>'));
    $check_array = array();

	foreach($alle_deltagere as $r)
	{

            echo "<div>";
            //$navn_array = array($r['navn'],$r['efternavn']) ;
           // $navn = join(" ",$navn_array); 



            if(!in_array($r['navn'],$check_array)) {

                /*echo "<div style='float:right;'>";
                    if($r['aktiv'] == 0) {
                     echo anchor("admin/aktiver/".$r['id']," ","class='passiv'");

                    }
                    else {
                     echo anchor("admin/deaktiver/".$r['id']," ","class='aktiv'");

                    }

                echo "</div>";*/



					//echo "<form action='".base_url()."admin/test' style='float:right;'>".nbs()."</form>";
				?>
				<div class="deltager-holder" >
					<span class="admin-options" style='float:right;display:none'> 
							<form class="af" method="post" action="<?php echo base_url();?>admin/slet_deltager">
								<input type="hidden" name="deltager_id" value="<? echo $r['id'];?>" />
								<input class="rubrik" type="submit" value="Slet" 
								onClick="if(confirm('Slet deltageren'))
								return true;
								else return false" />
						
							<button type="button" class="rubrik " >Rediger</button>
							<button type="button" class="rubrik ny_pc_til_deltager_link">Ny pc</button>
						</form>
						
					</span><?
					//echo "<span style='float:right;'>".nbs()."rediger </span>".nbs();
					//echo "<span style='float:right;'>".nbs()."ny pc </span>".nbs();                
					echo "<h3 class='rubrik user_character_link' id='".$r['id']."'>".$r['navn']."</h3>";

					echo "<div class='ny_pc_til_deltager_form' style='display:none;'>";
					echo form_open("admin/opret_ny_pc_eksisterende_deltager");
						$this->load->view("forms/opret_individ_form");
					//	echo "<p class='user_characters".$r['id']."' style='display:display;padding:10px;border:1px solid #B7937B;'>";
						//echo "<b class='rubrik'>Spiller rollen som:</b><br/>";
						//echo "<p class='rubrik' id='".$r['id_rollespiller']."' style=''>";
						echo form_input("rollespiller_id",$r['id']);
						echo form_submit("","opret ny pc til ".$r['navn']);
					echo form_close();
					echo "</div>";			
				echo "</div>";						
				
				echo "<ul class='leaders'>";
					foreach($alle_pcs as $s)
	                {
						if($s['id_rollespiller'] == $r['id'] ) {

							echo "<li><span>".anchor("almanak/side/".$s['id_karakter'],$s['navn']." ","class='ink'")."<b> ".anchor("admin/pc_to_npc/".$s['id_karakter']."/".$r['id'],"NPC","class='rubrik'")."</b></span>";
							echo "<span class='rubrik'><b>level ".$s['level']."</b></span>"; 

						}


					}	
						echo "</ul>";
						
						
						?>
					
						<?
                 /*	foreach($user_pcs as $s)
	                {
						//echo $s['id_rollespiller'];
						//echo $r['id_rollespiller'];


                        $navn_array2 = array($s['navn'],$s['efternavn']);
                        $navn2 = join(" ",$navn_array2); 

                        if($s['id_rollespiller'] == $r['id_rollespiller']) {

							echo "<span class='rubrik' style='float:right;' >Level ".$s['level']." ".$s['profession']." ";
							echo anchor("admin/pc_to_npc/".$s['id_karakter']."/".$r['id_rollespiller'],"npc","class='ink' id='make_npc'");		
							echo "</span>";
	
						
							echo anchor("almanak/side/".$s['id_karakter'],$s['karakter'],"class='ink'").br();
												
							
                        }   


                    }*/
             //   echo "</p>";
         


                echo br();
            }

            echo "</div>";
            $check_array[] = $r['navn'];

	}


?>

<script type="text/javascript">
//$(document).ready(function() {

$(".deltager-holder").hover(function() {
	$(this).children(".admin-options").toggle();
});

$("button.ny_pc_til_deltager_link").click(function() {
	var deltagerHolder = $(this).parents(".deltager-holder");
	$(deltagerHolder).children(".ny_pc_til_deltager_form").toggle();
});
$("button.opret_ny_deltager_link").click(function() {
	//var deltagerHolder = $(this).parents(".deltager-holder");
	$("#opret_ny_deltager_form").toggle();
});


</script>


<script type="text/javascript">
//$(document).ready(function() {

$(".user_character_link").click(function() {
	var id = $(this).attr('id');
	//alert(id);
	$(".user_characters" + id).slideToggle("fast");

});

$("#opret_ny_deltager_link").click(function() {
	$("#opret_ny_deltager_form").slideToggle("fast");

});

$("#check_new_pc").click(function() {
	$("#eksisting_character").hide();
	$("#new_player_character").show();
	$("#role-holder").val("new_pc");
});

$("#check_exist_pc").click(function() {
	$("#eksisting_character").show();
	$("#new_player_character").hide();
	$("#role-holder").val("exist_pc");
});

$("#check_none").click(function() {
	$("#eksisting_character").hide();
	$("#new_player_character").hide();
	$("#role-holder").val("none");
});

/*$("#role-pick").click(function() {
	var rolePickType = "none";
	//alert("sdfdsfdf");
	//new_pc_show

*/
	/*if() {
		
	}*/
	

	/*$("#role-holder").val(rolePickType);
});*/


//});
</script>



